<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/4/2
 * Time: 18:10
 */

namespace App\Http\Middleware;

use Closure;


class HomeLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //如果请求的session里面存在用户信息，则继续
        if($request->session()->get('wbtoken')) {
            return $next($request);
        }elseif($request->session()->get('user.id')){
//            return redirect('/');
            return $next($request);
        }else{
            return redirect('/login');
        }
    }
}